#include <gtkmm/main.h>
#include <gtkmm/window.h>
#include <gtkmm/drawingarea.h>
#include <cairomm/context.h>
struct Point
{
    int m_x,m_y;
};


class Window:protected Gtk::DrawingArea
{
public:
    Window();
    virtual ~Window();
    //Point current();
protected:
    virtual bool on_expose_event(GdkEventExpose* event);
private:
    Point current_;
};
Window::Window()
{
}
Window::~Window()
{
}

bool Window::on_expose_event(GdkEventExpose* event)
{
    Glib::RefPtr<Gdk::Window> window = get_window();
    if(window)
    {
        Gtk::Allocation allocation = get_allocation();
        const int width = allocation.get_width();
        const int height = allocation.get_height();
// coordinates for the center of the window
        int xc, yc;
        xc = width / 2;
        yc = height / 2;
        Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
        cr->set_line_width(10.0);
// clip to the area indicated by the expose event so that we only redraw
// the portion of the window that needs to be redrawn
        cr->rectangle(event->area.x, event->area.y,
                      event->area.width, event->area.height);
        cr->clip();
// draw red lines out from the center of the window
        cr->set_source_rgb(0.8, 0.0, 0.0);
        cr->move_to(0, 0);
        cr->line_to(xc, yc);
        cr->line_to(0, height);
        cr->move_to(xc, yc);
        cr->line_to(width, yc);
        cr->stroke();
    }
    return true;
}

    
int main(int argc, char* argv[])
{
    Gtk::Main kit(argc, argv);
    Gtk::Window win;
    win.set_title("Drawing area");
    Window w;
    win.add(w);
    w.show();
    Gtk::Main::run(win);
    return 0;
}
